YAHOO.namespace('springmole');


(function () {

	// see also : http://www.satyam.com.ar/yui/2.8.0/requery.html
	
	/**
	 * http://www.satyam.com.ar/yui/2.6.0/requery.html
	 * 
	 * @param {Object} newRequest
	 */
	YAHOO.widget.DataTable.prototype.requery = function (newRequest) {
		var ds = this.getDataSource();
		if (ds instanceof YAHOO.util.LocalDataSource) {
			ds.liveData = newRequest;
			ds.sendRequest("",
				{
					success: this.onDataReturnInitializeTable,
					failure: this.onDataReturnInitializeTable,
					scope: this
				}
			);
		} else {
			ds.sendRequest(
				(newRequest === undefined?this.get('initialRequest'):newRequest),
				{
					success: this.onDataReturnInitializeTable,
					failure: this.onDataReturnInitializeTable,
					scope: this
				}
			);
		}
	};	
	
	
	var Event = YAHOO.util.Event,
		Dom = YAHOO.util.Dom;
		
		
	/**
	 * 
	 * @param {Object} el
	 * @param {Object} userConfig
	 */
	YAHOO.springmole.SpringMolePanel = function (el, userConfig) {
		YAHOO.springmole.SpringMolePanel.superclass.constructor.call(this, el, userConfig);
	};
	
	YAHOO.lang.extend(YAHOO.springmole.SpringMolePanel, YAHOO.widget.Panel, {
		
		_panelResize: null,
	
		SPRING_MOLE_PANEL_CLASS: 'springMole-panel',
		TOOL_BAR_BUTTON_CLASS: 'button-toolBar',
		
		init: function (el, userConfig) {
			YAHOO.springmole.SpringMolePanel.superclass.init.call(this, el, userConfig);
			
			this.cfg.setProperty('effect' , {
				effect: YAHOO.widget.ContainerEffect.FADE,
				duration: 0.25
			});
			
			this.setFooter('');
		},
		
		initDefaultConfig: function () {
			YAHOO.springmole.SpringMolePanel.superclass.initDefaultConfig.call(this);
		},
		
		render: function (parentNode) {
			YAHOO.springmole.SpringMolePanel.superclass.render.call(this, parentNode);
			
			YAHOO.util.Dom.addClass(this.element, this.SPRING_MOLE_PANEL_CLASS);
			
			this._panelResize = new YAHOO.util.Resize(this.id, {
				handles: ['br'],
				autoRatio: false,
				minWidth: 100,
				minHeight: 30,
				status: false
			});
							
			this._panelResize.on('resize', function (args) {
				this.cfg.setProperty('height', args.height + 'px');
			}, this, true);			
		} 
		
	}); // extend Panel

}());